package main.java.com.zjh.automation.listener;

import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

public class MyKeyListener extends KeyAdapter {

    @Override
    public void keyTyped(KeyEvent e) {
       if(e.getKeyChar() == '+'){
           System.out.println("进入");
           Robot r = null;//创建自动化工具对象
           try {
               r = new Robot();
           } catch (AWTException awtException) {
               awtException.printStackTrace();
           }
           //切换应用
           r.keyPress(KeyEvent.VK_ALT);
           r.delay(100);
           r.keyPress(KeyEvent.VK_TAB);
           r.delay(100);
           r.keyRelease(KeyEvent.VK_ALT);
           r.delay(100);
           r.keyRelease(KeyEvent.VK_TAB);
           r.delay(100);
           //按下回车
           r.keyPress(KeyEvent.VK_ENTER);
           r.delay(100);
//           r.keyPress(KeyEvent.VK_ENTER);
//           r.delay(100);
//           //粘贴剪贴板的内容
//           r.keyPress(KeyEvent.VK_CONTROL);
//           r.delay(100);
//           r.keyPress(KeyEvent.VK_V);
//           r.delay(100);
//           r.keyRelease(KeyEvent.VK_CONTROL);
//           r.delay(100);
//           r.keyRelease(KeyEvent.VK_V);
//           //按下回车
//           r.keyPress(KeyEvent.VK_ENTER);
//           r.delay(100);
//           r.keyPress(KeyEvent.VK_ENTER);
//           r.delay(100);
       }
    }
}
